import { IUIEngineInputParam } from '@/core/interface';
import { UIEngine } from './ui-engine';

/**
 * 项显示
 *
 * @export
 * @class ItemVisibleUIEngine
 * @extends {UIEngine<A>}
 * @template A
 */
export class ItemVisibleUIEngine<A> extends UIEngine<A> {

    setItemVisible(args: IUIEngineInputParam<A>) {
        const { scriptCode,itemName } = this.rowData;
        if (!scriptCode) {
            return;
        }
        const { navParam: viewparam, navContext: context, data, model } = args;
        const env = App.getProjectSetting();
        try {
            const itemDetail:any = model?.find((item:any)=>{
                return item.name == itemName;
            })
            return itemDetail.visible =  eval(scriptCode);
        } catch (error) {
            return true;
        }
    }
}
